package com.limh.readers.widget.recyclerview.adapter

import android.content.Context
import android.view.LayoutInflater
import com.limh.readers.widget.recyclerview.base.ItemViewDelegate
import com.limh.readers.widget.recyclerview.base.ViewHolder


/**
 * Function:
 * author: limh
 * time:2017/7/28
 */
abstract class CommonAdapter<T>(mContext: Context, var mLayoutId: Int, protected var mDatas: List<T>) :
        MultiItemTypeAdapter<T>(mContext, mDatas) {
    protected var mInflater: LayoutInflater = LayoutInflater.from(mContext)

    init {

        addItemViewDelegate(object : ItemViewDelegate<T> {

            override val itemViewLayoutId: Int
                get() = mLayoutId

            override fun isForViewType(item: T, position: Int): Boolean {
                return true
            }

            override fun convert(holder: ViewHolder, t: T, position: Int) {
                this@CommonAdapter.convert(holder, t, position)
            }
        })
    }

    protected abstract fun convert(holder: ViewHolder, t: T, position: Int)


}